package com.smasher.pdf.afreakyelf

import android.content.Context
import com.rajat.pdfviewer.PdfViewerActivity
import com.rajat.pdfviewer.util.saveTo

object AfreakyelfUtil {
    fun launchPdfFromUrl(context: Context, url: String) {

//        Headers can be passed like this, be default header will be empty.
//        val url = "http://10.0.2.2:5000/download_pdf" // Use 10.0.2.2 for Android emulator to access localhost
//        val headers = mapOf("Authorization" to "123456789")

        context.startActivity(
            PdfViewerActivity.launchPdfFromUrl(
                context = context,
                pdfUrl = url,
                pdfTitle = "PDF Title",
                saveTo = saveTo.ASK_EVERYTIME,
                enableDownload = true
            )
        )
    }

    fun launchPdfFromUri(context: Context, uri: String) {
        context.startActivity(
            PdfViewerActivity.launchPdfFromPath(
                context = context, path = uri,
                pdfTitle = "Title", saveTo = saveTo.ASK_EVERYTIME, fromAssets = false
            )
        )
    }

    fun launchPdfFromAssets(context: Context, uri: String) {
        context.startActivity(
            PdfViewerActivity.launchPdfFromPath(
                context = context, path = uri,
                pdfTitle = "Title", saveTo = saveTo.ASK_EVERYTIME, fromAssets = true
            )
        )
    }
}
